package com.longlong.controller.adminApi;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.longlong.entity.RegistrationForm;
import com.longlong.entity.RegistrationPrimary;
import com.longlong.mapper.RegistrationCompetitionMapper;
import com.longlong.mapper.RegistrationFormMapper;
import com.longlong.mapper.RegistrationPrimaryMapper;
import com.longlong.vo.PaginationVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/primary")
public class primary {
    @Autowired
    private RegistrationFormMapper registrationFormMapper;
    @Autowired
    private RegistrationCompetitionMapper registrationCompetitionMapper;
    @Autowired
    private RegistrationPrimaryMapper registrationPrimaryMapper;



    /**
     * 分页查询海选报名赛事
     * @param paginationVo
     * @return
     */
    @PostMapping("/getPrimaryList")
    private Object getPrimaryList(@RequestBody PaginationVo paginationVo){
        System.out.println(paginationVo.toString());
        Page<RegistrationPrimary> page = new Page<>(paginationVo.getPage(),paginationVo.getSize());
        QueryWrapper<RegistrationPrimary> wrapper = new QueryWrapper<>();
        wrapper.eq("rp.competition_id",paginationVo.getCompetitionId());
        return registrationPrimaryMapper.selectPrimaryPage(page,wrapper);
    }

    /**
     * 获取全部赛事信息
     * @return
     */
    @PostMapping("/getAllCompetitions")
    private Object getAllCompetitions(){
        return registrationCompetitionMapper.selectList(null);
    }
    @PostMapping("/confirmAudition")
    private Object confirmAudition(@RequestBody RegistrationForm registrationForm){
        registrationForm.setParticipateStatus(2);
        System.out.println(registrationForm.toString());
        return registrationFormMapper.updateById(registrationForm);
    }
}
